package com.training.action.chenhao;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.training.pojo.chengshu.UDept;
import com.training.pojo.chengshu.UUser;
import com.training.service.chenhao.EmpService;

public class EmplistAction extends ActionSupport {
	private EmpService empservice;
	private List<UUser> list;
	private List<UDept> dlist;
    private int page=1;
	private static final Integer MAX = 5;
	private Integer totalPages;
	public String execute() {
	    int rowCount =empservice.empsize(); 
		totalPages = ((rowCount % MAX) == 0)?(rowCount/MAX):(rowCount/MAX + 1);
		if(page < 1){
			page = 1;
		}
		if(page > totalPages){
			page = totalPages;
		}
		int start = (page - 1) * MAX+1;
		int end=start+MAX-1;
		list = empservice.emplist(start,end);

		// for(int i=0;i<list.size();i++){
		System.out.println("查询到的人员数为:" + list.size());
		// }
      dlist=empservice.deptname();
      //System.out.println("dlist"+dlist.size());
		return SUCCESS;
	}

	public EmpService getEmpservice() {
		return empservice;
	}

	public void setEmpservice(EmpService empservice) {
		this.empservice = empservice;
	}

	public List<UUser> getList() {
		return list;
	}

	public void setList(List<UUser> list) {
		this.list = list;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public Integer getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(Integer totalPages) {
		this.totalPages = totalPages;
	}

	
	public List<UDept> getDlist() {
		return dlist;
	}

	public void setDlist(List<UDept> dlist) {
		this.dlist = dlist;
	}
	
}
